package org.ilead.iserve.service.impl;

import java.util.List;

import org.ilead.iserve.dao.IResourceDAO;
import org.ilead.iserve.dao.IUsersDAO;
import org.ilead.iserve.model.Resource;
import org.ilead.iserve.model.Users;
import org.ilead.iserve.service.IResourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResourceService implements IResourceService {
	
	 private static final Logger log = LoggerFactory.getLogger(ResourceService.class);
	 
	 private IResourceDAO resourceDAO=null;
	
	 public void setResourceDAO(IResourceDAO resourceDAO) {
		this.resourceDAO = resourceDAO;
	}
	public void addResource(Resource r) throws Exception {
		resourceDAO.save(r);		
	 }
	 public void delResource (Integer r) throws Exception {
		 resourceDAO.delete(findById(r));
	 }
	 public List<Resource> findAll() {
		 return resourceDAO.findAll();
	 }
	 public List<Resource> findByType(int type) {
		 return resourceDAO.findByType(type);
	 }
	 public Resource findById(Integer id) {
		 return resourceDAO.findById(id);
	 }
	 
	 public void updateResource (Resource r) throws Exception {
		 resourceDAO.attachDirty(r);
	 }
}
